<?php


namespace app\model;


class Hotel extends BaseModel
{
    public function user(){
        return $this->HasOne(User::class , 'id' , 'user_id');
    }
    protected $updateTime = '';

    public function room(){
        return $this->hasMany(Room::class , 'hotel_id' , 'id');
    }

    public function getLogoUrlAttr($value){
        if ($value)return env('aliyun.bucket') . $value;
        return null;
    }

    public function getImgUrlAttr($values , $data){
        if ($values){
            $result = [];
            $urls = json_decode($values, true);
            if (is_array($urls)){
                foreach ($urls as $url){
                    $result[] = env('aliyun.bucket') . $url;
                }
            }else if($urls != null){
                $result[] = env('aliyun.bucket') . $urls;
            }

            return $result;
        }
        return null;
    }
}
